<?php
/**
 * Created by PhpStorm.
 * User: yzr
 * Date: 1/27/2021
 * Time: 15:12
 */
namespace app\common\model\coin;

use app\common\model\base\A3Mall;

class CoinPlatform extends A3Mall
{
    protected $name = "coin_platform";

    public const CAHNNEL_HB=1;
    public const CAHNNEL_BA=2;
    public const CAHNNEL_OK=3;
    /**
     * 类型
     */
    protected static $mapping=[
        self::CAHNNEL_HB=>'火币',
        self::CAHNNEL_BA=>'Binance',
        self::CAHNNEL_OK=>'OKEx',
    ];

    public static function getChannelList()
    {
        return self::$mapping;
    }

    public static function getChannelText(int $channel)
    {
        return self::$mapping[$channel] ?? '';
    }

    protected $type = [
        "id"=>"integer",
        "pid"=>"integer",
        "icon"=>"string",
        "status"=>"integer",
    ];



    public function getList($condition,$size=10,$page=1){
        $count = $this->where($condition)->count();
        $data = $this->where($condition)->order('id','DESC')->paginate($size);
        return [
            "count"=>$count,
            "data"=>$data->items()
        ];
    }
}
